package com.dd.census.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dd.census.entity.SysUserRole;
import com.dd.census.service.impl.SysUserRoleServiceImpl;
import com.dd.census.tools.resopnse.ResultResponse;
import com.dd.census.tools.resopnse.emums.ResultStatus;

@RestController
@RequestMapping(value = "census/sysUserRole")
public class SysUserRoleController{

	private static final Logger logger = LoggerFactory.getLogger(SysUserRoleController.class);

	@Autowired
	private SysUserRoleServiceImpl sysUserRoleService;

	@RequestMapping("/{id}")
	public ResultResponse<Object> getById(@PathVariable("id") Integer id, HttpServletRequest request) {
		try {
			SysUserRole sysUserRole = new SysUserRole();
			sysUserRole.setUserId(id);
			
			return ResultResponse.buildSuccess(sysUserRoleService.selectByRoleId(sysUserRole));
		} catch (Exception e) {
			// 系统异常
			logger.error("Internal Server Error", e);
			return ResultResponse.buildFailure(ResultStatus.FATAL_ERROR);
		}
	}

}
